package org.pearl.validation.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.pearl.validation.demo.pojo.dto.UserInfoDTO;
import org.pearl.validation.demo.pojo.entity.User;
import org.pearl.validation.demo.pojo.query.UserInfoServiceQuery;
import org.pearl.validation.demo.pojo.query.UserInfoWebQuery;
import org.pearl.validation.demo.pojo.vo.UserVo;
import org.pearl.validation.demo.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author td
 * @since 2021-05-29
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;


    @GetMapping("/getUserInfo")
    public UserVo getUserInfo(UserInfoWebQuery userInfoWebQuery) {
        // 转换UserInfoWebQuery=》UserInfoServiceQuery
        UserInfoServiceQuery userInfoServiceQuery = new UserInfoServiceQuery();
        BeanUtils.copyProperties(userInfoWebQuery, userInfoServiceQuery);
        // 查询对象转换 UserInfoDTO=》UserVo
        UserInfoDTO userInfo = userService.getUserInfo(userInfoServiceQuery);
        UserVo userVo = new UserVo();
        BeanUtils.copyProperties(userInfo, userVo);
        return userVo;
    }
}

